package com.gourd.common.enums;

import com.alibaba.fastjson.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

/**
 * 附件类型
 *
 * @author gourd
 * @create 2018-07-04 15:41
 **/
@JSONType(serializeEnumAsJavaBean = true)
public enum FileTypeEnum {
    ppt("ppt","ppt"),
    file("file","文本"),
    word("word","word"),
    excel("excel","excel"),
    pdf("pdf","pdf"),
    video("video","视频"),
    txt("txt","文本"),
    png("png","图片"),
    bpm("bpm","bpm"),
    jpg("jpg","图片"),
    gif("gif","gif")
    ;


    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private String label;

    FileTypeEnum(String value, String label) {
        this.value = value;
        this.label = label;
    }

    /**
     * 根据lable获取枚举
     * @param label
     * @return
     */
    public static FileTypeEnum getByLabel(String label){
        for (FileTypeEnum fileTypeEnum: FileTypeEnum.values()) {
            if (fileTypeEnum.getLabel().equals(label)) {
                return fileTypeEnum;
            }
        }
        return null;
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static FileTypeEnum getByValue(String value){
        for (FileTypeEnum fileTypeEnum: FileTypeEnum.values()) {
            if (fileTypeEnum.getValue().equals(value)) {
                return fileTypeEnum;
            }
        }
        return null;
    }

}
